package com.light.common.base;

import lombok.Data;
import org.apache.catalina.connector.Response;

/**
 * @Tittle ResponseResult
 * @Description
 * @Author yhr
 * @Date 2019/4/17 13:38
 * @Version 1.0
 */
@Data
public class ResponseResult<T> {
    private T data;

    private String requestId;

    private String resultCode;

    private String resultMsg;

    private String solution;

    private boolean success;

    public ResponseResult(T data, String resultCode, boolean success) {
        this.data = data;
        this.resultCode = resultCode;
        this.success = success;
    }

    public ResponseResult(String resultMsg, String resultCode, boolean success) {
        this.resultMsg = resultMsg;
        this.resultCode = resultCode;
        this.success = success;
    }

    public ResponseResult(String resultCode, boolean success) {
        this.resultCode = resultCode;
        this.success = success;
    }

    public static ResponseResult success(){
        return new ResponseResult(String.valueOf(Response.SC_OK),true);
    }

    public static ResponseResult success(Object data){
        return new ResponseResult(data,String.valueOf(Response.SC_OK),true);
    }

    public static ResponseResult error(String resultCode,String data){
        return new ResponseResult(data,resultCode,false);
    }

    public static ResponseResult error(String resultMsg){
        return new ResponseResult(resultMsg,"400",false);
    }


}
